﻿using System;

namespace UniRx.Operators
{
	// Token: 0x0200024A RID: 586
	internal class AsSingleUnitObservableObservable<T> : OperatorObservableBase<Unit>
	{
		// Token: 0x06000D83 RID: 3459 RVA: 0x00040284 File Offset: 0x0003E684
		public AsSingleUnitObservableObservable(IObservable<T> source) : base(source.IsRequiredSubscribeOnCurrentThread<T>())
		{
			this.source = source;
		}

		// Token: 0x06000D84 RID: 3460 RVA: 0x00040299 File Offset: 0x0003E699
		protected override IDisposable SubscribeCore(IObserver<Unit> observer, IDisposable cancel)
		{
			return this.source.Subscribe(new AsSingleUnitObservableObservable<T>.AsSingleUnitObservable(observer, cancel));
		}

		// Token: 0x040007A8 RID: 1960
		private readonly IObservable<T> source;

		// Token: 0x0200024B RID: 587
		private class AsSingleUnitObservable : OperatorObserverBase<T, Unit>
		{
			// Token: 0x06000D85 RID: 3461 RVA: 0x000402AD File Offset: 0x0003E6AD
			public AsSingleUnitObservable(IObserver<Unit> observer, IDisposable cancel) : base(observer, cancel)
			{
			}

			// Token: 0x06000D86 RID: 3462 RVA: 0x000402B7 File Offset: 0x0003E6B7
			public override void OnNext(T value)
			{
			}

			// Token: 0x06000D87 RID: 3463 RVA: 0x000402BC File Offset: 0x0003E6BC
			public override void OnError(Exception error)
			{
				try
				{
					this.observer.OnError(error);
				}
				finally
				{
					base.Dispose();
				}
			}

			// Token: 0x06000D88 RID: 3464 RVA: 0x000402F4 File Offset: 0x0003E6F4
			public override void OnCompleted()
			{
				this.observer.OnNext(Unit.Default);
				try
				{
					this.observer.OnCompleted();
				}
				finally
				{
					base.Dispose();
				}
			}
		}
	}
}
